// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'
import FastClick from 'fastclick'
import App from '@/App'
import VueRouter from '@/router/index'
import { WechatPlugin, AjaxPlugin } from 'vux'

Vue.use(WechatPlugin) //微信插件
Vue.use(AjaxPlugin)  //ajax插件
Vue.use(Vuex)

/*Vue.http.get(GV.ROOT + 'api', ({data}) => {
  Vue.wechat.config(data.data)
})*/

const store = new Vuex.Store({}) // 这里你可能已经有其他 module

store.registerModule('lulushunche', { // 名字自己定义
  state: {
    isLoading: false,
    headerTitle: '',
    isLogin: true,
  },
  mutations: {
    updateLoadingStatus (state, payload) {
      state.isLoading = payload.isLoading
    },
    updateTitleStatus (state, payload) {
      state.headerTitle = payload.headerTitle
    },
    updateLoginStatus (state, payload) {
      state.isLogin = payload.isLogin
    },
  }
})

const router = VueRouter;

router.beforeEach(function (to, from, next) {
  store.commit('updateLoadingStatus', {isLoading: true})
  next()
})

router.afterEach(function (to) {
  store.commit('updateLoadingStatus', {isLoading: false})
  var hs='路路顺车'
  if(to.name=='pub')
  	hs='发布信息'
  else if(to.name=='my')
  	hs='用户中心'
  else if(to.name=='detail')
  	hs='顺车详情'
  store.commit('updateTitleStatus', {headerTitle: hs})
})

FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
var the_app=new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app-box')
